package com.kdd.campus.sh.convert;

import com.alibaba.fastjson.JSONObject;
import com.kdd.campus.sh.dto.QueryOrderItemDto;
import com.kdd.campus.sh.po.ShOrderItem;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: fcp
 * @Date: 2020/7/17 12:47
 * @Description:
 */
@Mapper
public interface QueryOrderItemConvert extends GeneralConvert<ShOrderItem, QueryOrderItemDto>{
    QueryOrderItemConvert INSTANCE = Mappers.getMapper(QueryOrderItemConvert.class);

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        List<ShOrderItem> orderItems = new ArrayList<>();
        for (int i = 0;i < 30;i++){
            ShOrderItem orderItem = new ShOrderItem().setProductId(Long.valueOf(i + "")).setProductImg("img" + i).setPrice(Double.parseDouble(i+"")).setNum(i).setProductName("name" + i);
            orderItems.add(orderItem);
        }
        List<QueryOrderItemDto> list = JSONObject.parseObject(JSONObject.toJSONString(orderItems), List.class);
        System.out.println(list);
//        List<QueryOrderItemDto> queryOrderItemDtos = QueryOrderItemConvert.INSTANCE.poListToDtoList(orderItems);
//        System.out.println(queryOrderItemDtos);
        System.out.println(System.currentTimeMillis() - start);
    }
}
